package 力扣;

import java.time.Instant;
import java.util.ArrayList;

/**
 * @author yyq
 * @create 2022-06-14 8:47
 */
public class leetcode452 {
    public static void main(String[] args) {
        leetcode452 leetcode452=new leetcode452();
        System.out.println(leetcode452.findMinArrowShots(new int[][]{{10, 16}, {2, 8}, {1, 6}, {7, 12}}));
    }
    public int findMinArrowShots(int[][] points) {

        ArrayList<int[]> list=new ArrayList<>();
        for (int i=0;i<points.length;i++){
            
        }
        for (int i = 0; i < points.length; i++) {
            boolean flag=true;
            int[] x=points[i];
            for (int j = 0; j < list.size(); j++) {
                int[] ints = list.get(j);
                if(x[0]<=ints[0]&&ints[1]<=x[1]){
                    list.remove(j);
                    list.add(new int[]{ints[0],ints[1]});
                    flag=false;
                }
                if(ints[0]<=x[0]&&x[1]<=ints[0]){
//                    list.remove(j);
//                    list.add(new int[]{x[0],x[1]});
                    flag=false;
                }
                if(x[0]<=ints[0]&&ints[0]<=x[1]&&x[1]<=ints[1]){
                    list.remove(j);
                    list.add(new int[]{ints[0],x[1]});
                    flag=false;
                }
                if(ints[0]<x[0]&&x[0]<=ints[1]&&ints[1]<=x[1]){
                    list.remove(j);
                    list.add(new int[]{x[0],ints[1]});
                    flag=false;
                }
            }
            if(flag)
                list.add(points[i]);
        }
        return list.size();
    }
}
